<template>
	<view>
		<view class="wrap">
			<view class="w-swiper"><u-swiper :list="list" border-radius="10" interval="5000"></u-swiper></view>

			<view class="content" v-if="userinfo.bumen == '人力部'">
				<view class="content-title">人力资源</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage()">
						<view class="ite"><u-icon name="photo" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">部门</view>
					</u-grid-item>
					<u-grid-item>
						<view class="ite blue"><u-icon name="man-delete" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">员工</view>
					</u-grid-item>
					<u-grid-item>
						<view class="ite red"><u-icon name="home" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">合同到期人员</view>
					</u-grid-item>
					<u-grid-item @click="goPage('/pages/user/add')">
						<view class="ite fense"><u-icon name="home" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">新增员工</view>
					</u-grid-item>
				</u-grid>
			</view>

			<view class="content" v-if="userinfo.is_schoolmaner">
				<view class="content-title">学校管理</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage('/pages/school/list')">
						<view class="ite blue"><u-icon name="list" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">班级列表</view>
					</u-grid-item>
					<u-grid-item>
						<view class="ite blue" @click="goPage('/pages/school/list')"><u-icon name="grid" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">创建班级</view>
					</u-grid-item>
					<u-grid-item @click="goPage('/pages/school/student')">
						<view class="ite shenlan"><u-icon name="email-fill" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">分配学生</view>
					</u-grid-item>
					<u-grid-item @click="goPage('/pages/school/charge')">
						<view class="ite"><u-icon name="man-delete" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">报名收费</view>
					</u-grid-item>
				</u-grid>
			</view>

			<view class="content" v-if="userinfo.is_schoolmaner">
				<view class="content-title">财务管理</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage('/pages/finance/price')">
						<view class="ite blue"><u-icon name="red-packet" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">定价</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/finance/report')">
						<view class="ite apply-statistics">
							<u-image width="36rpx" height="38rpx" src="../../static/icon/index-report-icon.png"></u-image>
						</view>
						<view class="grid-text">财务申报</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/finance/reportLaborCost')">
						<view class="ite apply-history">
							<u-image width="36rpx" height="38rpx" src="../../static/icon/index-reportLaborCost-icon.png"></u-image>
						</view>
						<view class="grid-text">人力上报</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/caiwu/weekfee')">
						<view class="ite apply-apply">
							<u-image width="40rpx" height="38rpx" src="../../static/icon/index-weekfee-icon.png"></u-image>
						</view>
						<view class="grid-text">基数申报</view>
					</u-grid-item>
				</u-grid>
			</view>
			
			<view class="content">
				<view class="content-title">财务审计</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage('/pages/finance/apply')">
						<view class="ite apply-add">
							<u-image width="40rpx" height="40rpx" shape="circle" src="../../static/icon/index-add-icon.png"></u-image>
						</view>
						<view class="grid-text">新增申请</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/finance/applyList?type=apply')">
						<view class="ite apply-apply">
							<u-image width="40rpx" height="40rpx" src="../../static/icon/index-apply-icon.png"></u-image>
						</view>
						<view class="grid-text">审批列表</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/finance/applyList')">
						<view class="ite apply-history">
							<u-image width="40rpx" height="40rpx" shape="circle" src="../../static/icon/index-history-icon.png"></u-image>
						</view>
						<view class="grid-text">历史记录</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/finance/applyStatistics')">
						<view class="ite apply-statistics">
							<u-image width="40rpx" height="40rpx" src="../../static/icon/index-statistics-icon.png"></u-image>
						</view>
						<view class="grid-text">统计信息</view>
					</u-grid-item>
				</u-grid>
			</view>

			<view class="content">
				<view class="content-title">个人信息</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage('/pages/user/register')">
						<view class="ite blue"><u-icon name="account" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">资料修改</view>
					</u-grid-item>
					<u-grid-item @click="logout">
						<view class="ite blue"><u-icon name="man-delete" :size="40" color="#fff"></u-icon></view>
						<view class="grid-text">退出</view>
					</u-grid-item>
				</u-grid>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			list: [],
			userinfo: ''
		};
	},
	onLoad() {
		this.baseurl = this.$u.http.config.baseUrl;
		if(uni.getStorageSync('userinfo') == '' || uni.getStorageSync('storage_time') == '') {
			uni.redirectTo({
				url: '../login/login'
			});
		} else {
			this.userinfo = uni.getStorageSync('userinfo');
		}
		
		this.getSwiperList();
	},
	computed: {},
	methods: {
		getSwiperList(){
			let _this = this;
			this.$u.post('/api/index/index').then(res => {
				_this.list = res.swiper_list; 
			})
		},
		goPage(url) {
			setTimeout(() => {
				uni.navigateTo({
					url: url
				});
			}, 500);
		},
		logout() {
			uni.clearStorageSync();
			uni.redirectTo({
				url: '../login/login'
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.w-swiper {
	margin: 15rpx 20rpx 50rpx;
	overflow: hidden;
}

.content {
	padding: 0rpx 30rpx 20rpx;
	.content-title {
		font-size: 26rpx;
		font-weight: bold;
		margin-bottom: 15rpx;
	}
	.ite {
		width: 80rpx;
		height: 80rpx;
		background-color: #ffaa00;
		border-radius: 15rpx;
		vertical-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.blue {
		background-color: RGB(49, 138, 253);
	}
	.fense {
		background-color: #ffaa00;
	}
	.red {
		background-color: RGB(254, 115, 9);
	}
	.whtie {
		background-color: #fff;
	}
	.shenlan {
		background-color: RGB(50, 112, 247);
	}
	.lvse {
		background-color: RGB(0, 210, 185);
	}
	.grid-text {
		font-size: 24rpx;
		margin-top: 4rpx;
		color: #333;
	}
	
	.apply-add {
		background-color: #45cdae;
	}
	
	.apply-apply {
		background-color: #288eed;
	}
	
	.apply-history {
		background-color: #ed8238;
	}
	
	.apply-statistics{
		background-color: #de5c48;
	}
}
</style>
